package com.hjx.other;

/**
 * @author houjinxin
 * @version 创建时间：2019/10/30.
 */
public class MaxValue {

    public static int max(int[] a) {

        return twoMax(a);
    }

    public static int twoMax(int[] other){
        if (other.length == 1){
            return other[0];
        }
        if (other.length == 2){
            return Math.max(other[0], other[1]);
        } else {
            int[] newArr = new int[other.length - 1];
            System.arraycopy(other, 1, newArr, 0, newArr.length);

            return Math.max(other[0], twoMax(newArr));
        }
    }

    public static void main(String[] args) {
        int[] a = {1,2,3,4,5,6,7,8,9};

        System.out.println(max(a));
    }
}
